package com.wh1200.mybatis.xmlless.model.component


/**
 *
 * @author 吴昊
 * @date 2023/12/21 14:06
 * @since v4.0.0
 * @version 1.0
 */
class TestConditionGroup {

  private val conditions: MutableList<TestConditionDeclaration> = mutableListOf()

  fun toSql(): String {
    return conditions.distinct().joinToString(" and ") { it.toSql() }
  }

  fun add(condition: TestConditionDeclaration) {
    conditions.add(condition)
  }

  fun hasCondition(): Boolean {
    return conditions.isNotEmpty()
  }

  fun addAll(list: List<TestConditionDeclaration>) {
    conditions.addAll(list)
  }

}
